package com.manager;

import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.SQLException;

import com.entity.Users;
import com.util.ConnectionFactory;
import com.util.DatabaseUtil;

public class UserManager {
    public boolean isValid(Users user) throws ClassNotFoundException{
        
        boolean flag = false;
        
        Connection con = null;
        Statement st = null;
        ResultSet rs = null;
        try {
            con = ConnectionFactory.getConnection();
            st = con.createStatement();
            String sql = "select * from users where username='" + user.getUsername() + "' and password='" + user.getPassword() + "'";
            rs = st.executeQuery(sql);
            if(rs.next()){
                flag = true;
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }finally{
            DatabaseUtil.release(rs, st, con);
        }
        return flag;
    }
}
